package com.carful;

import com.carful.xigua.modules.user.service.impl.AuthServiceImpl;
import com.carful.xigua.modules.user.service.impl.RoleServiceImpl;
import com.carful.xigua.modules.user.service.impl.UserServiceImpl;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;

/**
 * @author ad
 * Date 2024/7/11 11:09
 */

@SpringBootApplication
@MapperScan("com.carful.xigua.modules.*.mapper")
@EnableScheduling
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @Bean
    public ApplicationRunner initializer(AuthServiceImpl authService,
                                         RoleServiceImpl roleService,
                                         UserServiceImpl userService) {
        return args -> {
            try {
                authService.init();
                roleService.init();
                userService.init();
            } catch (Exception e) {
                e.printStackTrace();
            }
        };
    }
}
